/*     */ package net.sourceforge.appgen.job;
/*     */ 
/*     */ import java.util.List;
/*     */ import net.sourceforge.appgen.connector.ProfileConnector;
/*     */ import net.sourceforge.appgen.editor.MappingDataEditor;
/*     */ import net.sourceforge.appgen.model.ConnectionInformation;
/*     */ import org.eclipse.core.runtime.IProgressMonitor;
/*     */ import org.eclipse.core.runtime.IStatus;
/*     */ import org.eclipse.core.runtime.Status;
/*     */ import org.eclipse.core.runtime.SubProgressMonitor;
/*     */ import org.eclipse.core.runtime.jobs.Job;
/*     */ import org.eclipse.swt.widgets.Display;
/*     */ 
/*     */ public class GetEntityListJob extends Job
/*     */ {
/*     */   private MappingDataEditor editor;
/*     */   private ConnectionInformation connectionInformation;
/*     */ 
/*     */   public GetEntityListJob(ConnectionInformation connectionInformation, MappingDataEditor editor, String text)
/*     */   {
/*  43 */     super(text);
/*     */ 
/*  45 */     this.editor = editor;
/*  46 */     this.connectionInformation = connectionInformation;
/*     */   }
/*     */ 
/*     */   protected IStatus run(IProgressMonitor monitor)
/*     */   {
/*  51 */     monitor.beginTask("Parse entity from table", 103);
/*     */     try
/*     */     {
/*  54 */       monitor.subTask("Connect to database: " + this.connectionInformation.getName());
/*     */ 
/*  56 */       ProfileConnector connector = new ProfileConnector(this.connectionInformation);
/*     */ 
/*  58 */       connector.connect();
/*     */ 
/*  60 */       if (monitor.isCanceled()) {
/*  61 */         monitor.done();
/*     */ 
/*  63 */         return Status.CANCEL_STATUS;
/*     */       }
/*     */ 
/*  66 */       monitor.worked(1);
/*     */ 
/*  68 */       int count = connector.getEntityListCount();
/*     */ 
/*  70 */       if (monitor.isCanceled()) {
/*  71 */         monitor.done();
/*     */ 
/*  73 */         return Status.CANCEL_STATUS;
/*     */       }
/*     */ 
/*  76 */       monitor.worked(1);
/*     */ 
/*  78 */       SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 100);
/*  79 */       subMonitor.beginTask("Starting parse table...", count);
/*  80 */       subMonitor.setTaskName("Parse table");
/*     */ 
/*  82 */       final List entityList = connector.getEntityList(subMonitor);
/*     */ 
/*  84 */       if (monitor.isCanceled()) {
/*  85 */         monitor.done();
/*     */ 
/*  87 */         return Status.CANCEL_STATUS;
/*     */       }
/*     */ 
/*  90 */       subMonitor.done();
/*     */ 
/*  92 */       Display.getDefault().asyncExec(new Runnable() {
/*     */         public void run() {
/*  94 */           GetEntityListJob.this.editor.onEntityListChanged(entityList);
/*     */         }
/*     */       });
/*  98 */       monitor.worked(1);
/*     */     } catch (Exception e) {
/* 100 */       throw new RuntimeException(e);
/*     */     }
/*     */ 
/* 104 */     monitor.done();
/*     */ 
/* 106 */     return Status.OK_STATUS;
/*     */   }
/*     */ }

/* Location:           C:\Users\lzl6066\Downloads\net.sourceforge.appgen_1.2.0\plugins\net.sourceforge.appgen_1.2.0.201002031718\
 * Qualified Name:     net.sourceforge.appgen.job.GetEntityListJob
 * JD-Core Version:    0.6.0
 */